<template>
</template>
<script setup>
import { onMounted } from 'vue'

onMounted(() => {
    sseData();
});

//SSE推流
//SSE流推送
const eventSource = ref(null);

const sseData = () => {
    console.log("ss")

    eventSource.value = new EventSource('activity/test/sse', {
        withCredentials: true,
        headers: { 'Accept': 'text/event-stream', 'Content-Type': 'text/event-stream' }
    });

    eventSource.value.onmessage = (e) => {
        const data = JSON.parse(e.data);
        console.log("收到：", data);
    };

};

</script>